<?php

$dsn = 'pgsql:dbname=XXXXXX host=XXXXX port=5432';
$user = 'XXXXXXXXX';
$password = 'XXXXXXXX';

echo "<html><head><title>利用履歴</title></head><body>";
echo "<center>利用履歴";
echo "<br />";
echo '<table border="1">';
echo "<tr>";
echo "<td>id</td><td>ユーザ名</td><td>課金額</td><td>日時</td>";
echo "</tr>";

try{
	$conn = new PDO($dsn, $user, $password);
	$stmt = $conn->query("SELECT * FROM account");

	while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
		echo "<tr>";
		echo "<td>".$row["account_id"]."</td>";
		echo "<td>".$row["username"]."</td>";
		echo "<td>".$row["payment"]."円</td>";
		echo "<td>".$row["ins_date"]."</td>";
		echo "</tr>";
	}

	unset($conn);
}catch (PDOException $e){
	print('Error:'.$e->getMessage());
	die();
}

echo "</table>";
echo "<br><a href=\"./index.php\">戻る</a><br></center></body></html>";
